home *** CD-ROM | disk | FTP | other *** search
/ Aminet 5 / Aminet 5 - March 1995.iso / Aminet / dev / misc / LEDA_gene.lha / LEDA-3.1c-generic / prog / graphics / windows.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-05  |  1.5 KB  |  72 lines

  1. #include <LEDA/window.h>
  2.  
  3.  
  4. main()
  5. {
  6.    // we open five windows w1, w2, w3, w4, and w5
  7.    // for points, segments, lines, and circles
  8.    // w5 is used as a log-window
  9.  
  10.    window w1(550,410,window::min,window::min,"DRAW POINTS");
  11.    window w2(550,410,window::max,window::min,"DRAW SEGMENTS");
  12.    window w3(550,410,window::min,window::max,"DRAW LINES");
  13.    window w4(550,410,window::max,window::max,"DRAW CIRCLES");
  14.    window w5(160,480,window::center,window::center,"CENTER WINDOW");
  15.  
  16.    w5.set_show_coordinates(false);
  17.  
  18.    double  x,y;
  19.    point   p;
  20.    segment s;
  21.    line    l;
  22.    circle  c;
  23.  
  24.    window* w;
  25.  
  26.  
  27.    // wait for mouse click and get pointer to the corresponding window 
  28.  
  29.    while(read_mouse(w,x,y) != 3)  
  30.    { 
  31.      if (w == &w1) // draw points
  32.      { put_back_event();
  33.        w1 >> p;
  34.        w1.draw_point(p,blue);
  35.        w5.message("w1: point");
  36.        continue;
  37.       }
  38.  
  39.      if (w == &w2) // draw segments
  40.      { put_back_event();
  41.        w2 >> s;
  42.        w2.draw_segment(s,violet);
  43.        w5.message("w2: segment");
  44.        continue;
  45.       }
  46.  
  47.      if (w == &w3) // draw lines
  48.      { put_back_event();
  49.        w3 >> l;
  50.        w3.draw_line(l,green);
  51.        w5.message("w3: line");
  52.        continue;
  53.       }
  54.  
  55.      if (w == &w4) // draw circles
  56.      { put_back_event();
  57.        w4 >> c;
  58.        w4.draw_circle(c,orange);
  59.        w5.message("w4: circle");
  60.        continue;
  61.       }
  62.  
  63.      if (w == &w5) // clear log-window
  64.      { w5.clear();
  65.        continue;
  66.       }
  67.  
  68.     }
  69.  
  70.    return 0;
  71. }
  72.